package xiao.ke.serviceinvoker.controller;/**
 * @author XuXiaoK
 * @create 2020-01-19 19:14
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

/**
 *@Author XiaoKe
 *@Date 2020/1/19 19:14
 *@Description TODO
 */

@RestController
public class InvokerController {

   @Autowired
   RestTemplate restTemplate;

    @RequestMapping("/router")
    public String router() {

        String json = restTemplate.getForObject("http://SERVICE-PROVIDER/person/1", String.class);
        return json;
    }

    @RequestMapping("/hello")
    public String hello(String name) {
        HashMap<String, String> map = new HashMap<>();
        map.put("name", name);
        return restTemplate.getForObject("http://SERVICE-PROVIDER/hello?name={name}", String.class, map);
    }
}
